//
//  UIScrollView+JTExtension.m
//  JTBaseLib_Example
//
//  Created by kenter on 2019/7/4.
//  Copyright © 2019 kenter. All rights reserved.
//

#import "UIScrollView+JTExtension.h"
#import "JTBaseLib.h"

@implementation UIScrollView (JTExtension)

- (MJRefreshStateHeader *)addMJRefreshHeaderWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock
{
    MJRefreshStateHeader *header = [MJRefreshStateHeader headerWithRefreshingBlock:refreshingBlock];
    [header setTitle:@"" forState:MJRefreshStateIdle];
    self.mj_header = header;
    
    return header;
}

- (MJRefreshAutoStateFooter *)addMJRefreshFooterWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock
{
    MJRefreshAutoStateFooter *footer = [MJRefreshAutoStateFooter footerWithRefreshingBlock:refreshingBlock];
    [footer setTitle:@"" forState:MJRefreshStateIdle];
    self.mj_footer = footer;
    return footer;
}

- (MJRefreshGifHeader *)addMJRefreshHeaderWithPullingGif:(NSArray <UIImage *>* )pullingImages
                                           refreshingGif:(NSArray <UIImage *>* )refresingImages
                                         refreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock
{
    MJRefreshGifHeader *header = [MJRefreshGifHeader headerWithRefreshingBlock:refreshingBlock];
    if (!JTIsEmptyArray(pullingImages)) {
        [header setImages:pullingImages forState:MJRefreshStatePulling];
    }
    if (!JTIsEmptyArray(refresingImages)) {
        [header setImages:refresingImages forState:MJRefreshStateRefreshing];
    }
    [header setTitle:@"" forState:MJRefreshStateIdle];
    self.mj_header = header;
    
    return header;
}

- (MJRefreshAutoGifFooter *)addMJRefreshFooterWithPullingGif:(NSArray <UIImage *>* )pullingImages
                                               refreshingGif:(NSArray <UIImage *>* )refresingImages
                                             refreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock
{
    MJRefreshAutoGifFooter *footer = [MJRefreshAutoGifFooter footerWithRefreshingBlock:refreshingBlock];
    if (!JTIsEmptyArray(pullingImages)) {
        [footer setImages:pullingImages forState:MJRefreshStatePulling];
    }
    if (!JTIsEmptyArray(refresingImages)) {
        [footer setImages:refresingImages forState:MJRefreshStateRefreshing];
    }
    [footer setTitle:@"" forState:MJRefreshStateIdle];
    self.mj_footer = footer;
    
    return footer;
}

@end
